<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .p1 {
      color: red;
    }
    .p2 {
      color: blueviolet;
    }
    .redbg {
      background-color: red;
    }
    .yellowbg {
      background-color: yellow;
    }
    .isRed {
      color: red;
    }
    .isBlue {
      color: blue;
    }
    .big {
      font-size: 40px;
    }
  </style>
</head>
<body>
  <div id="app">
    <p>动态样式：class、style。class适合批量修改样式；style适合精准修改样式</p>
    <input type="text" v-model="class1">
    <!-- 变量替换 -->
    <p v-bind:class="class1">我是一段文字</p>
    <!-- 语法糖 -->
    <!-- 字符串拼接 -->
    <p :class="class2+'bg'">我是一段文字</p>
    <!-- 对象形式，冒号后面的值为真，才会有这个class -->
    <p :class="{isRed: isTrue, 'big': true}">我是一段文字</p>
    <!-- 数组形式 -->
    <p :class="[isTrue?'isRed':'isBlue', 'big']">我是一一一一段文字</p>
    <hr>
    <!-- 字符串拼接 -->
    <p :style="{'font-size': num+'px', color: fontColor}">我是两段文字</p>
    <p :style="[style1, style2]">我是两段文字</p>
  </div>
  <script src="../vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        class1: 'p2',
        class2: 'yellow',
        isTrue: true,
        num: 60,
        fontColor: '#56a5f1',
        style1: {
          border: '1px solid red',
          color: 'red'
        },
        style2: {
          lineHeight: 5
        }
      }
    })
  </script>
</body>
</html>